/**********************************************************************
 Copyright (C) 2009 Jaakko Vuori

 This file is part of FlexiWorker.
 For more information, see <http://code.google.com/p/flexi-worker/>

 FlexiWorker is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 FlexiWorker is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with FlexiWorker.  If not, see <http://www.gnu.org/licenses/>.
 **********************************************************************/

#ifndef PRESENCELOGMODEL_H
#define PRESENCELOGMODEL_H

#include <QDateTime>
#include <QDate>
#include <QMap>
#include "logparser.h"

class TimeFrame
{
public:
    QDateTime m_startTime;
    QDateTime m_endTime;
};

class PresenceLogModel : public LogParserHandler
{
public:
    PresenceLogModel();

public:
    QList<TimeFrame> presenceTimes(const QDate& date) const;
    QList<TimeFrame> workingTimes(const QDate& date) const;
    void updateWorkingTime(QDate date, int index, TimeFrame workingTime);

protected:  //from LogParserHandler
    void newDay(const QDate& date);
    void newEntry(const QDateTime& startTime, const QDateTime& endTime);

private:
    QDate m_currentDate;
    QMap<QDate, QList<TimeFrame> > m_entries;
    QMap<QDate, QList<TimeFrame> > m_adjustedWorkTimes;
};

#endif // PRESENCELOGMODEL_H
